package booroo.basic;

import java.util.Scanner;

public class J07_CalendarV1 {

	public static void main(String[] args) {
		// 2005년 1월 달력 출력
		final String title = "\t\tJ a n u a r y 2005";
		final String hdrline = "----------------------------------------------------";
		final String hdrdays = "Sun\tMon\tTue\tWed\tThu\tFri\tSat";
		
		System.out.println(title);
		System.out.println(hdrline);
		System.out.println(hdrdays);
		
		// 달력출력 v1		
		/*for(int i = 1; i <= 31; ++i){
			if(i % 7 == 0){
				System.out.println(i + "");
			}
			else System.out.print(i + "\t");
		}*/
		
		// 달력출력 v2 (공백포함)
		System.out.println();
		Scanner sc = null;
		int skipday;  // 달력 공백 수
		int year;
		int j;
		sc = new Scanner(System.in);
		System.out.print("Enter year : ");
		year = sc.nextInt();
		sc.close();
		skipday = ((year-1)*365+(year-1)/4-(year-1)/100+(year-1)/400 % 7)+1;
		j = skipday;
				
		for(int i = 1; i <= 31 + j; ++i, --skipday){
			if(skipday >= 1){
				System.out.print(" " + "\t");
				}
			else if(i % 7 == 0)
				System.out.println((i-j) + "");
			else System.out.print((i-j) + "\t");
			}
		
		}
	
}
